import 'package:flutter/material.dart';

import '../router/router.dart';

class BottmBarMenuGuestPage extends StatelessWidget {
  final ValueNotifier<int> tabIndexNotifier;
  final List<Router> routes = [
    Router(
      routerDelegate: AppRouterDelegate(
        routeFactory: AppRouterFactory.routeFactory,
      ),
      routeInformationParser: AppRouterInformationParser(),
      routeInformationProvider: AppRouterInformationProvider(location: '/'),
    ),
    Router(
      routerDelegate: AppRouterDelegate(
        routeFactory: AppRouterFactory.routeFactory,
      ),
      routeInformationParser: AppRouterInformationParser(),
      routeInformationProvider: AppRouterInformationProvider(location: '/'),
    ),
  ];

  BottmBarMenuGuestPage({
    @required this.tabIndexNotifier,
  });

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder(
      valueListenable: tabIndexNotifier,
      builder: (context, tabIndex, child) {
        return Scaffold(
          body: IndexedStack(
            children: [
              ...routes,
            ],
            index: tabIndex,
          ),
          bottomNavigationBar: BottomNavigationBar(
            backgroundColor: Colors.green,
            items: [
              BottomNavigationBarItem(
                icon: Icon(Icons.adb),
                label: 'tab1',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.phone_iphone),
                label: 'tab2',
              ),
            ],
            type: BottomNavigationBarType.fixed,
            currentIndex: tabIndex,
            onTap: (index) => tabIndexNotifier.value = index,
          ),
        );
      },
    );
  }
}
